# Maintainer:  Bartłomiej Piotrowski <barthalion@gmail.com>
# Contributor: Thomas S Hatch <thatch45 at gmail dot com>

pkgname=libaio
pkgver=0.3.112
pkgrel=2
pkgdesc="The Linux-native asynchronous I/O facility (aio) library"
arch=('x86_64')
url="https://pagure.io/libaio"
license=('LGPL')
source=(https://releases.pagure.org/libaio/${pkgname}-${pkgver}.tar.gz)
sha256sums=('ab0462f2c9d546683e5147b1ce9c195fe95d07fac5bf362f6c01637955c3b492')

build() {
  cd "$srcdir/$pkgname-$pkgver"
  # AIO library is a thin wrapper around kernel syscalls, it does not use stdlib
  # and other helpers like stack protection libraries
  CFLAGS="-march=${CARCH/_/-} -mtune=generic -O2 -pipe"
  make
}

check() {
  cd "$srcdir/$pkgname-$pkgver"

  # work around gcc warning (-Werror) in test suite
  sed -i '/strncpy/s#sizeof(TEMPLATE)#sizeof(template)#' harness/cases/19.t
  sed -i '/strncpy/s#sizeof(TEMPLATE)#sizeof(temp_file)#' harness/cases/21.t

  make partcheck
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  make prefix="$pkgdir/usr" install
}

